/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-08-01
 * Time: 22:35
 */
public class Main {
    public int removeElement(int[] nums, int val) {
        int i = 0;
        int length = nums.length;
        while (i < length) {
            if (nums[i] == val) {
                for (int j = i; j < length - 1; j++) {
                    nums[j] = nums[j + 1];
                }
                length--;
            }else {
                i++;
            }
        }
        return length;
    }
}
